
typedef unsigned int size_t;

extern void memset_16(char *s, int c, size_t count);

static void memset_1(void *s, int c, size_t count)
{
	char *xs = s;

	while (count--)
		*xs++ = c;
	return s;
}

void* memset(char *s, int c, size_t count){
    char* p = s;
    unsigned long align = 16;
    size_t size, left = count;
    int n, i;
    unsigned long address = (unsigned long) p;
    unsigned long data = 0ULL;
	if (address & (align - 1)) {
		//fixme: 这里应该是 对齐的后半段
		size = align - address & (align - 1);
		memset_1(p, c, size);
		p = p + size;
		left = count - size;
	}
	/*align 16 bytes*/
	if (left > align) {
		n = left / align;
		left = left % align;

		memset_16(p, data, 16*n);

		if (left)
			memset_1(p + 16*n, c, left);
	}
    return s;

}